import axios from '@/utils/request'

export async function getSectionTree(data){
  const res = await axios.post('/SectionManagement/getTree', data);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}


export async function getDicItemByPaged(data){
  const res=await axios.post('/DictionaryItemManagement/QueryByPage', data);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}

export async function deleteDictionaryItem(id){
  const res = await axios.post(`/DictionaryItemManagement/Delete/${id}`);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}

export async function deleteSection(id){
  const res = await axios.post(`/SectionManagement/Delete/${id}`);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}

export async function CreateDictionaryItemManagement(data){
  const res = await axios.post(`/DictionaryItemManagement`, data);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}

export async function CreateSection(data){
    const res = await axios.post(`/SectionManagement`, data);
    if (res.code == 1) {
      return res.data;
    } else {
      return Promise.reject(new Error(res.message));
    }
  }

export async function updateDictionaryItemManagement(id,data){
  const res = await axios.post(`/DictionaryItemManagement/Update/${id}`, data);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}

export async function updateSection(id,data){
  const res = await axios.post(`/SectionManagement/Update/${id}`, data);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}
